import Vue from 'vue';
import Vuex from 'vuex';
import { getDepartTree } from '@/api/system/tbSysDept';
Vue.use(Vuex)
const state = {
	departList: []
}
const getters = {}
const actions = {
	//获取部门列表数据
	async getDepartList({ commit }) {
		let params = { basePId: '0', del: '1' };
		let result = await getDepartTree(params).then(res => res.data)
		if (result.code === '0') {
			let datas = result.data || [];
			commit('SET_DEPART_DATA', datas);
		} else {
			Promise.reject(new Error('faile'));
		}
	}
}
const mutations = {
	SET_DEPART_DATA: (state, d) => {
		state.departList = d;
		Vue.prototype.$local.set('departData', d);
	},
}
export default { state, getters, actions, mutations }